<?php
class Ctrl {
    protected $tpl_vars;
	public function __construct(){
	    $this->tpl_vars = array(
                        'styles' => array(),
                        'scripts' => array(),
                        'js_vars' => array(
                        ),
        );
		
	}
	
	protected function display($tpl_file){
        extract($this->tpl_vars);
        ob_start();
        require  TPLPATH.$tpl_file;
        $html= ob_get_clean();
        $html = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $html);
        $html = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $html);
        echo $html;
	}
	
	protected function fetch($tpl_file){
	    extract($this->_tpl_vars);
        ob_start();
        require  TPLPATH.$tpl_file;
        return ob_get_clean();
	}
	
	protected function assign(){
	    $args = func_get_args();
        for($i=0, $j=count($args);$i< $j;$i++){
            $this->tpl_vars[$args[$i]] = $args[$i+1];
            $i++;
        }
	}
	
	protected function assign_js_var(){
	    $args = func_get_args();
        for($i=0, $j=count($args);$i< $j;$i++){
            $this->tpl_vars['script_vars'][$args[$i]] = $args[$i+1];
            $i++;
        }
	}
	
    protected function set_styles(){
        $args = func_get_args();
        foreach ($args as $key) {
            $this->tpl_vars['styles'][] = $key;
        }
    }
    
    protected function set_scripts(){
        $args = func_get_args();
        foreach ($args as $key) {
        }
    }
}